home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / flying-6.11 / global.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-30  |  11.3 KB  |  383 lines

  1. #ifndef _global_h
  2. #    include "global.h"
  3. #endif
  4.  
  5. //
  6. // Im Modul global.C werden sΣmtliche Spielparameter wie Gr÷▀en,
  7. // KrΣfte ... festgehalten, damit sie an einer lokalen Stelle zugreifbar
  8. // sind. Die zugeordneten Werte sind Voreinstellungen, die durch eine
  9. // Konfigurationsdatei (wenn vorhanden) ⁿberschrieben werden k÷nnen.
  10. //
  11.  
  12. #ifndef _real_h
  13. #    include "real.h"
  14. #endif
  15. #ifndef _cannon_h
  16. #    include "cannon.h"
  17. #endif
  18. #ifndef _carrom_h
  19. #    include "carrom.h"
  20. #endif
  21. #ifndef _game_h
  22. #    include "game.h"
  23. #endif
  24. #ifndef _goal_h
  25. #    include "goal.h"
  26. #endif
  27. #ifndef _hockey_h
  28. #    include "hockey.h"
  29. #endif
  30. #ifndef _curling_h
  31. #    include "curling.h"
  32. #endif
  33. #ifndef _pball_h
  34. #    include "pball.h"
  35. #endif
  36. #ifndef _pool_h
  37. #    include "pool.h"
  38. #endif
  39. #ifndef _pool8_h
  40. #    include "pool8.h"
  41. #endif
  42. #ifndef _snooker_h
  43. #    include "snooker.h"
  44. #endif
  45. #ifndef _pocket_h
  46. #    include "pocket.h"
  47. #endif
  48.  
  49.  
  50. Real Billard::PresetA            = -25.0;
  51. Real Billard::PresetHaft        = 5.0;
  52. #ifndef __TURBOC__
  53. Real Billard::SlowGranularity    = 0.25;
  54. #else
  55. Real Billard::SlowGranularity    = 0.5;
  56. #endif
  57. Real Billard::FrameOffset        = 20.0;
  58. Real Billard::InnerCushion        =  4.0;
  59. Real Billard::OuterCushion        =  8.0;
  60.  
  61.  
  62.  
  63. Real Cannon::BallRadius        =   6.15 / 2;
  64. Real Cannon::TableWidth        = 224.0;
  65. Real Cannon::TableHeight    = 112.0;
  66.  
  67.  
  68. Real Carrom::Offset           = 0.01;
  69. Real Carrom::PresetA                = -400.0;
  70. Real Carrom::PresetHaft            = 5.0;
  71. Real Carrom::SlowGranularity    = 0.125;
  72. Real Carrom::FrameOffset        = 14.0;
  73. Real Carrom::ToPocket            =  2.0;
  74. Real Carrom::Cushion                =  6.0;
  75. Real Carrom::TableWidth            = 73.0;
  76. Real Carrom::TableHeight        = 73.0;
  77. Real Carrom::PocketRadius        =  6.20 / 2;
  78. Real Carrom::StoneRadius        =  3.30 / 2;
  79. Real Carrom::StrikerRadius        =  4.35 / 2;
  80. Real Carrom::StoneWeight        =  4.;        //  4 g
  81. Real Carrom::StrikerWeight        = 10.;        // 10 g
  82.  
  83. Real Carrom::ChargeGranularity    = 0.05;    // seconds
  84. Real Carrom::ChargeSpeed            = 400.;    // Charge per second
  85. Real Carrom::MaxCharge                = 400.;
  86. Real Carrom::ShootTime                = 0.1;    // seconds
  87. Real Carrom::PocketFrame    = 2.0;
  88. Real Carrom::PocketWidth    = 8.5;
  89.  
  90. Real CarromDemo::PresetA            = 0.0;
  91. Real CarromDemo::SlowGranularity    = 1.0;
  92.  
  93.  
  94.  
  95. Real Game::PresetA            = -10.0;
  96. Real Game::PresetHaft        = 10.0;
  97. Real Game::SlowGranularity    = 0.1;
  98. Real Game::NormalBallSize    = 1.2;
  99.  
  100. #ifndef __TURBOC__
  101. Real Game::ChargeGranularity    = 0.01;    // seconds
  102. Real Game::ChargeSpeed            = 250.;    // Charge per second
  103. Real Game::MaxCharge                = 300.;
  104. Real Game::ShootTime                = 0.1;    // seconds
  105. #else
  106. Real Game::ChargeGranularity    = 0.05;    // seconds
  107. Real Game::ChargeSpeed            = 250.;    // Charge per second
  108. Real Game::MaxCharge                = 300.;
  109. Real Game::ShootTime                = 0.2;    // seconds
  110. #endif
  111.  
  112.  
  113. Real Hockey::PresetA                = -100.0;
  114. Real Hockey::PresetHaft            = 5.;
  115. Real Hockey::SlowGranularity    = 0.125;
  116. Real Hockey::FrameOffset        =   5.0;
  117. Real Hockey::TableWidth            =  100.0;
  118. Real Hockey::TableHeight        =   70.0;
  119. Real Hockey::GoalSize            =  20.0;
  120. Real Hockey::DiscRadius            =   4.0;
  121. Real Hockey::HandRadius            =   6.0;
  122. Real Hockey::DiscWeight            =  4.;        //  4 g
  123. Real Hockey::HandWeight            = 10.;        // 10 g
  124. Real Hockey::GoalFrame            = 0.9;
  125. Real Hockey::GoalHeight            = 10.0;
  126. Real TestHockey::PresetA            = -400.0;
  127. Real TestHockey::SlowGranularity    = 0.01;
  128.  
  129.  
  130. Real Curling::PresetA                = -100.0;
  131. Real Curling::PresetHaft            = 5.;
  132. Real Curling::SlowGranularity    = 0.125;
  133. Real Curling::FrameOffset        =   0.0;
  134. Real Curling::TableWidth            =  100.0;
  135. Real Curling::TableHeight        =   40.0;
  136. Real Curling::GoalSize            =  20.0;
  137. Real Curling::Offset                    =  0.5;
  138. Real Curling::CurlRadius            =  2.0;
  139. Real Curling::CurlWeight            =  4.;        //  4 g
  140. Real Curling::KeeperFrame            = 0.9;
  141. Real Curling::KeeperHeight            = 6.0;
  142.  
  143.  
  144. Real Pool::Offset       = 0.05;
  145. Real Pool::EdgeRadius    = 0.3;
  146. Real Pool::EdgeAngle        = 50.;
  147. Real Pool::MidAngle        = 30.;
  148. Real Pool::TableWidth    = 200.0;
  149. Real Pool::TableHeight    = 100.0;
  150. Real Pool::PocketRadius    =   8.00 / 2.;
  151. Real Pool::BallRadius    =   5.72 / 2.;
  152. Real Pool::PocketFrame  = 2.0;
  153. Real Pool::PocketHeight   = 10.0;
  154.  
  155. Real Pool8Demo::PresetA            = 0.0;
  156. Real Pool8Demo::SlowGranularity    = 1.0;
  157.  
  158. Real PBallTop::WarpTime                = 0.02;    // Zeit zum Sprung auf Cursorposition
  159. Real PBallTop::LockedQueueDelay    = 0.25;    // Nachlauf des gelock'ten Queue
  160.  
  161. Real Snooker::TableWidth    = 350.0;
  162. Real Snooker::TableHeight    = 175.0;
  163. Real Snooker::BallRadius    =   5.24 / 2;
  164.  
  165. Real SnookerDemo::PresetA            = 0.0;
  166. Real SnookerDemo::SlowGranularity    = 1.0;
  167.  
  168.  
  169. /* ========================================================================== */
  170. /* ====                DO NOT EDIT BEYOND THIS LINE                      ==== */
  171. /* ========================================================================== */
  172.  
  173. typedef struct {
  174.     const char    *name;
  175.     Real            *val_addr;
  176. } KonfiParam;
  177.  
  178. static KonfiParam konfi[] = {
  179. { "Billard::FrameOffset",  &Billard::FrameOffset },
  180. { "Billard::InnerCushion",  &Billard::InnerCushion },
  181. { "Billard::OuterCushion",  &Billard::OuterCushion },
  182. { "Billard::PresetA",  &Billard::PresetA },
  183. { "Billard::PresetHaft",  &Billard::PresetHaft },
  184. { "Billard::SlowGranularity",  &Billard::SlowGranularity },
  185. { "Cannon::BallRadius",  &Cannon::BallRadius },
  186. { "Cannon::TableHeight",  &Cannon::TableHeight },
  187. { "Cannon::TableWidth",  &Cannon::TableWidth },
  188. { "Carrom::ChargeGranularity",  &Carrom::ChargeGranularity },
  189. { "Carrom::ChargeSpeed",  &Carrom::ChargeSpeed },
  190. { "Carrom::Cushion",  &Carrom::Cushion },
  191. { "Carrom::FrameOffset",  &Carrom::FrameOffset },
  192. { "Carrom::MaxCharge",  &Carrom::MaxCharge },
  193. { "Carrom::Offset",  &Carrom::Offset },
  194. { "Carrom::PocketFrame",  &Carrom::PocketFrame },
  195. { "Carrom::PocketRadius",  &Carrom::PocketRadius },
  196. { "Carrom::PocketWidth",  &Carrom::PocketWidth },
  197. { "Carrom::PresetA",  &Carrom::PresetA },
  198. { "Carrom::PresetHaft",  &Carrom::PresetHaft },
  199. { "Carrom::ShootTime",  &Carrom::ShootTime },
  200. { "Carrom::SlowGranularity",  &Carrom::SlowGranularity },
  201. { "Carrom::StoneRadius",  &Carrom::StoneRadius },
  202. { "Carrom::StoneWeight",  &Carrom::StoneWeight },
  203. { "Carrom::StrikerRadius",  &Carrom::StrikerRadius },
  204. { "Carrom::StrikerWeight",  &Carrom::StrikerWeight },
  205. { "Carrom::TableHeight",  &Carrom::TableHeight },
  206. { "Carrom::TableWidth",  &Carrom::TableWidth },
  207. { "Carrom::ToPocket",  &Carrom::ToPocket },
  208. { "CarromDemo::PresetA",  &CarromDemo::PresetA },
  209. { "CarromDemo::SlowGranularity",  &CarromDemo::SlowGranularity },
  210. { "Curling::CurlRadius",  &Curling::CurlRadius },
  211. { "Curling::CurlWeight",  &Curling::CurlWeight },
  212. { "Curling::FrameOffset",  &Curling::FrameOffset },
  213. { "Curling::GoalSize",  &Curling::GoalSize },
  214. { "Curling::KeeperFrame",  &Curling::KeeperFrame },
  215. { "Curling::KeeperHeight",  &Curling::KeeperHeight },
  216. { "Curling::Offset",  &Curling::Offset },
  217. { "Curling::PresetA",  &Curling::PresetA },
  218. { "Curling::PresetHaft",  &Curling::PresetHaft },
  219. { "Curling::SlowGranularity",  &Curling::SlowGranularity },
  220. { "Curling::TableHeight",  &Curling::TableHeight },
  221. { "Curling::TableWidth",  &Curling::TableWidth },
  222. { "Game::ChargeGranularity",  &Game::ChargeGranularity },
  223. { "Game::ChargeSpeed",  &Game::ChargeSpeed },
  224. { "Game::MaxCharge",  &Game::MaxCharge },
  225. { "Game::NormalBallSize",  &Game::NormalBallSize },
  226. { "Game::PresetA",  &Game::PresetA },
  227. { "Game::PresetHaft",  &Game::PresetHaft },
  228. { "Game::ShootTime",  &Game::ShootTime },
  229. { "Game::SlowGranularity",  &Game::SlowGranularity },
  230. { "Hockey::DiscRadius",  &Hockey::DiscRadius },
  231. { "Hockey::DiscWeight",  &Hockey::DiscWeight },
  232. { "Hockey::FrameOffset",  &Hockey::FrameOffset },
  233. { "Hockey::GoalFrame",  &Hockey::GoalFrame },
  234. { "Hockey::GoalHeight",  &Hockey::GoalHeight },
  235. { "Hockey::GoalSize",  &Hockey::GoalSize },
  236. { "Hockey::HandRadius",  &Hockey::HandRadius },
  237. { "Hockey::HandWeight",  &Hockey::HandWeight },
  238. { "Hockey::PresetA",  &Hockey::PresetA },
  239. { "Hockey::PresetHaft",  &Hockey::PresetHaft },
  240. { "Hockey::SlowGranularity",  &Hockey::SlowGranularity },
  241. { "Hockey::TableHeight",  &Hockey::TableHeight },
  242. { "Hockey::TableWidth",  &Hockey::TableWidth },
  243. { "PBallTop::LockedQueueDelay",  &PBallTop::LockedQueueDelay },
  244. { "PBallTop::WarpTime",  &PBallTop::WarpTime },
  245. { "Pool8Demo::PresetA",  &Pool8Demo::PresetA },
  246. { "Pool8Demo::SlowGranularity",  &Pool8Demo::SlowGranularity },
  247. { "Pool::BallRadius",  &Pool::BallRadius },
  248. { "Pool::EdgeAngle",  &Pool::EdgeAngle },
  249. { "Pool::EdgeRadius",  &Pool::EdgeRadius },
  250. { "Pool::MidAngle",  &Pool::MidAngle },
  251. { "Pool::Offset",  &Pool::Offset },
  252. { "Pool::PocketFrame",  &Pool::PocketFrame },
  253. { "Pool::PocketHeight",  &Pool::PocketHeight },
  254. { "Pool::PocketRadius",  &Pool::PocketRadius },
  255. { "Pool::TableHeight",  &Pool::TableHeight },
  256. { "Pool::TableWidth",  &Pool::TableWidth },
  257. { "Snooker::BallRadius",  &Snooker::BallRadius },
  258. { "Snooker::TableHeight",  &Snooker::TableHeight },
  259. { "Snooker::TableWidth",  &Snooker::TableWidth },
  260. { "SnookerDemo::PresetA",  &SnookerDemo::PresetA },
  261. { "SnookerDemo::SlowGranularity",  &SnookerDemo::SlowGranularity },
  262. { "TestHockey::PresetA",  &TestHockey::PresetA },
  263. { "TestHockey::SlowGranularity",  &TestHockey::SlowGranularity },
  264. { 0, 0 }            // end konfi
  265. };
  266.  
  267. void show_defaults() {
  268.     for (int i=0;i<sizeof(konfi)/sizeof(KonfiParam)-1;i++) {
  269.         printf( "%s = %g\n", konfi[i].name, (double)*konfi[i].val_addr );
  270.     }
  271. }
  272.  
  273. void load_konfi() {
  274. FILE        *fp;
  275. char        buffer[80];
  276.  
  277.     fp = fopen( PRESET_FILE, "r" );
  278.     if (!fp) {
  279.         sprintf(buffer,"%s/%s",DATA_DIRECTORY,PRESET_FILE);
  280.         fp = fopen( buffer, "r" );
  281.         if (!fp)        return;
  282.     }
  283.  
  284.     while( fgets( buffer, sizeof(buffer), fp )) {
  285.         if (strstr(buffer,"::")) {
  286.             char *ptr = buffer;
  287.             while( (ptr)&&!isspace(*ptr)&&*ptr!='=' )        ptr++;
  288.             if (!ptr)            break;
  289.             *ptr++ = '\0';
  290.             while( (ptr)&&isspace(*ptr)||*ptr=='=' )       ptr++;
  291.             if (!ptr)            break;
  292.  
  293.             for (int i=sizeof(konfi)/sizeof(KonfiParam)-2;i>=0;i--) {
  294.                 if (!strcmp(buffer,konfi[i].name)) {
  295.                     (*konfi[i].val_addr) = Real(atof(ptr));
  296.                     break;
  297.                 }
  298.             }
  299.             if (i<0) {
  300.                 printf( "%s: unknown parameter in %s", PRESET_FILE, buffer );
  301.             }
  302.         }
  303.     }
  304.     fclose(fp);
  305. }
  306.  
  307. #ifdef DEBUG
  308.  
  309. /* ========================================================================== */
  310.  
  311. typedef struct {
  312.     const char        *name;
  313.     unsigned long    mask;
  314. } DebugFlag;
  315.  
  316. static DebugFlag dbg[] = {
  317. { "AbortCalc",  AbortCalc },
  318. { "AbortReCalc",  AbortReCalc },
  319. { "AfterCollision",  AfterCollision },
  320. { "BMover",  BMover },
  321. { "BState",  BState },
  322. { "BeforCollision",  BeforCollision },
  323. { "CheckBoundary",  CheckBoundary },
  324. { "CollCalc",  CollCalc },
  325. { "ForceCalc",  ForceCalc },
  326. { "GameState",  GameState },
  327. { "Intro",  Intro },
  328. { "Loops",  Loops },
  329. { "Motion",  Motion },
  330. { "MoveAll",  MoveAll },
  331. { "ObjectInfo",  ObjectInfo },
  332. { "PBallHit",  PBallHit },
  333. { "PointerMove",  PointerMove },
  334. { "ShowColors",  ShowColors },
  335. { "ShowLight",  ShowLight },
  336. { "ShowRings",  ShowRings },
  337. { "ShowTurns",  ShowTurns },
  338. { "StickLevel",  StickLevel },
  339. { "Sync",  Sync },
  340. { "TCTrace",  TCTrace },
  341. { "UnixTrace",  UnixTrace },
  342. { "XWallHit",  XWallHit },
  343. { "YWallHit",  YWallHit },
  344. { "__Moves",  __Moves },
  345. { "__Rings",  __Rings },
  346. { "__ShowAll",  __ShowAll },
  347. { "xdb",  xdb },
  348. { "xwd",  xwd },
  349. { 0, 0 }        // end dbg
  350. };
  351.  
  352. void show_flags() {
  353. int    width = 0;
  354.  
  355.     for (int i=0;i<sizeof(dbg)/sizeof(DebugFlag)-1;i++) {
  356.         if (strlen(dbg[i].name)>width)        width = strlen(dbg[i].name);
  357.     }
  358.     width++;
  359.     int cols = 79/width;
  360.     int rows = (sizeof(dbg)/sizeof(DebugFlag)-1)/cols+1;
  361.     for (int r=0;r<rows;r++) {
  362.         for (int c=0;c<cols;c++) {
  363.             int entry = rows*c+r;
  364.             if (entry<sizeof(dbg)/sizeof(DebugFlag)-1)
  365.                                 printf( "%-*s", width, dbg[entry].name );
  366.         }
  367.         printf( "\n" );
  368.     }
  369. }
  370.  
  371. int set_debug( const char *flag_name ) {
  372.     for (int i=0;i<sizeof(dbg)/sizeof(DebugFlag)-1;i++) {
  373.         if (!strcmp(flag_name,dbg[i].name)) {
  374.             debug |= dbg[i].mask;
  375.             return 0;
  376.         }
  377.     }
  378.     return 1;
  379. }
  380.  
  381.  
  382. #endif
  383.